function getContentDetail(id,callback){
    var param = {
        id : id
    }
    $.post(window.serviceUrl+"content/getContentDetail", param, callback, 'json');
}

function getSimilarInfoData(id,keyWord,callback){
    var param = {
        id : id,
        keyWord: keyWord
    }
    $.post(window.serviceUrl+"content/similarInfoData", param, callback, 'json');
}

function showDetail() {
    var id = fnGet("id");
    getContentDetail(id,function(data){
        if(data.rtnCode == "000000"){
            $("#artitleTitle").html(data.responseData.title);
            document.title = data.responseData.title;
            var reg = new RegExp( '47.112.238.80', "g" );
            $("#articleContent").html(data.responseData.contentHtml.replace( reg , 'www.lyqzh.net' ));
            showSimilarInfo(id,data.responseData.keyword,data.responseData.channelName);
        }
    });
    var channel1 = fnGet("channel1");
    var channel2 = fnGet("channel2");
    if(channel1)
        $("#channel1").html(decodeURI(decodeURI(channel1)));
    if(channel2)
        $("#channel2").html("> "+decodeURI(decodeURI(channel2)));
}

function showSimilarInfo(id,keyWord,channelName){
    var content = '';
    //<li><a>》数字校园</a></li>
    getSimilarInfoData(id,keyWord,function(data){
        var list = data.responseData;
        $.each(list, function(i, item){
            content += '<li style="margin-bottom: 10px;"><a href="detail.html?id='+item.id+'&channel1='+channelName+'">》'+item.title+'</a></li>';
        });
        $("#similarInfo").html(content);
    });
}

function fnGet(sQueryKey,sUrl) {
    sUrl = sUrl?sUrl:window.location.href;
    var aUrlPart = sUrl.split("?");
    var aGet = new Array();
    if (aUrlPart[1]) {
        aGetPair = aUrlPart[1].split("&");
        for (var i = 0; i < aGetPair.length; i++) {
            aTmpArr = aGetPair[i].split("=");
            sKey = aTmpArr[0];
            aGet[sKey] = aTmpArr[1];
        }
    }
    return aGet[sQueryKey];
}